#include <QtGui/QApplication>
#include <QNetworkProxyFactory>
#include <QTextCodec>
#include <QLibraryInfo>
#include <QTranslator>
#include <QLocale>
#include "ui/mainwindow.h"
#include "core/core.h"
#include "settings/networksd.h"
#include "settings/pluginssd.h"

int main(int argc, char *argv[]){
	QApplication a(argc, argv);

	a.setWindowIcon(QIcon(":/icon.svg"));
	a.setApplicationName( "Beaver" );

	//FIXME
	//move to settings, user should has ability to change this option
	QNetworkProxyFactory::setUseSystemConfiguration(true);

	//ustawiamy kodowanie
	QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
	QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
	QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));

	//Ładujemy polskie tłumaczenia komunikatów Qt
	QTranslator qtTranslator;
	qtTranslator.load("qt_" + QLocale::system().name(),
		  QLibraryInfo::location(QLibraryInfo::TranslationsPath));
	a.installTranslator(&qtTranslator);

	//initiate our Singleton
	if( Core::instance() == NULL )
		qFatal("cannot create CORE");

	Core::instance()->registerSettingPage( new NetworkSD() );
	Core::instance()->registerSettingPage( new PluginsSD() );

    MainWindow w;
    w.show();
	return a.exec();
}
